package com.martian.controller;

import com.martian.common.exception.SysException;
import com.martian.common.wrapper.ResultWrapper;
import com.martian.pojo.dto.ActorSimpleDto;
import com.martian.service.ActorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @author martian
 * @version V1.0.0
 * @Description
 * @date 2023-05-20 17:12
 */
@CrossOrigin
@Api(value = "CastController", tags = {"演员API"})
@RestController
@RequestMapping("/actor")
public class ActorController {
    @Resource
    ActorService actorService;

    @ApiOperation(value = "查询电影的演员", produces = "application/json")
    @GetMapping("/visitor/selectMovieActor")
    public ResultWrapper selectMovieCasts(@RequestParam Integer movieId){
        try{
            ArrayList<ActorSimpleDto> actorSimpleDto = actorService.selectMovieCasts(movieId);
            return ResultWrapper.successWithData(actorSimpleDto);
        }catch (SysException e){
            return ResultWrapper.failure(e.getMessage());
        }
    }
}
